package com.video.main_video.manager.handle.comment;

import com.video.main_video.api.Api;
import com.video.main_video.dao.request.comment.CommentDeleteRequest;
import com.video.main_video.dao.response.comment.CommentDeleteResponse;
import com.video.main_video.manager.handle.ApiHandler;
import com.video.main_video.manager.mapper.CommentChildMapper;
import com.video.main_video.manager.mapper.CommentReplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Api
public class CommentDeleteManager implements ApiHandler<CommentDeleteRequest, CommentDeleteResponse> {

    @Autowired
    CommentReplyMapper replyMapper;
    @Autowired
    CommentChildMapper commentMapper;

    @Override
    @Transactional
    public CommentDeleteResponse handler(CommentDeleteRequest commentDeleteRequest) {

        deleteComments(commentDeleteRequest.getCommentId());
        CommentDeleteResponse res=new CommentDeleteResponse();
        res.setCode(200);
        res.setMsg("删除成功");
        return res;
    }
    private void deleteComments(String commentId){
        replyMapper.deleteComment(commentId);
        commentMapper.deleteComment(commentId);
    }
}
